function steamroller(arr) {
    if (!Array.isArray(arr))
        return [arr];
    let ret = [];
    arr.forEach(
        function (v) {
            ret = ret.concat(steamroller(v));
        });
    return ret;
}

console.log(steamroller([1, [1, [3, 4]]]));
